import React, { Component } from 'react';

class Listadd extends Component {
  
  constructor(props) {
    super(props)
    // 创建 ref 
    this.ipt = React.createRef()
  }
  render() {
    const { handleAddItem } = this.props
    return (
      <React.Fragment>
         <h1>Todolist</h1>
          <div>
            {/* 指定 ref */}
            <input type="text" ref={ this.ipt }/>
            <button onClick={ () => handleAddItem(this.ipt.current.value) }>添加</button>
          </div>
      </React.Fragment>
    );
  }
}

export default Listadd;
